package com.snap.vseries.adapter;

import android.content.Context;
import android.view.View;

import com.snap.vseries.R;
import com.snap.vseries.base.BaseRecycleAdapter;
import com.snap.vseries.base.BaseViewHolder;
import com.snap.vseries.bean.ExpEntity;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;

public class HistoryAdapter extends BaseRecycleAdapter<ExpEntity> {

    public HistoryAdapter(Context context, List<ExpEntity> dataList) {
        super(context, dataList);
    }

    @Override
    public void bindData(BaseViewHolder holder, ExpEntity data, int position) {
        SimpleDateFormat format = new SimpleDateFormat("hh:mm d MMM yyyy", Locale.US);
        String time = format.format(new Date(data.getStartTime()));
        holder.setText(R.id.tv_name, (data.getDeviceTag()==null?"N/A":data.getDeviceTag())+"_"+data.getName())
                .setText(R.id.tv_date, time);
        if (data.isRead()) {
            holder.setViewVisibility(R.id.new_tv, View.GONE);
        } else {
            holder.setViewVisibility(R.id.new_tv, View.VISIBLE);
        }
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.layout_history_item;
    }

    @Override
    public void updateData(List<ExpEntity> dataList) {
        super.updateData(dataList);
    }
}
